#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 100010;
LL a[N], b[N];
int n, m;
// 对于区间加法，做法仍然是转换成差分
// 而对于区间求和，通过推理可得答案为 (b1 + b2 + ... + b_n-1) * (n + 1) - (b1 + b2 * 2 + bx * x)

int lowbit(int x) { return x & -x; }

void add(int x, int y)
{
    for(int i = x; i <= n; i += lowbit(i))
        a[i] += y, b[i] += (LL)x * y;
}

LL sum(int x)
{
    LL sum = 0, sub = 0;
    for(int i = x; i; i -= lowbit(i)) 
        sum += a[i], sub += b[i];
    // cout << sum << '  ' << sub << endl;
    return sum * (x + 1) - sub;
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
    {
        int tmp; cin >> tmp;
        add(i, tmp), add(i + 1, -tmp);
    }
    // for(int i = 1; i <= n; ++i)
    //     cout << a[i] << ' ';
    // cout << endl;
    for(int i = 0; i < m; ++i)
    {
        char op;
        cin >> op;
        if(op == 'Q')
        {
            int x, y;
            cin >> x >> y;
            cout << sum(y) - sum(x - 1) << endl;
        }
        else
        {
            int l, r, d;
            cin >> l >> r >> d;
            add(l, d), add(r + 1, -d);
        }
    }
    return 0;
}